Flask = Widget.extend({
	runningAction:null,
	ctor:function(){
		this._super();
		this.init();
		this.initAction();
		this.setTag(TAG_FLASK_ALL);
	},
	init:function(){
		this.body = new Button(this, 10, TAG_FLASK, "#flask/flask1.png", this.callback,this);
		
		var lid=new Button(this.body,10,TAG_FLASK_LID,"#flask/flask01.png",this.callback,this);
		lid.setPosition(this.body.width*0.5,this.body.height*0.93);
	},
	show:function(){
		var show=new Button(this.body,10,TAG_SHOW,"#show.png",this.callback,this);
		show.setPosition(cc.p(this.body.width*1.2,this.body.height*0.85));
		show.setOpacity(0);
		var fadein=cc.fadeIn(1);
		var fadeout=cc.fadeOut(1);
		show.runAction(cc.sequence(fadein,cc.delayTime(1),fadeout));
	},
	show1:function(){
		var show=new Button(this.body,10,TAG_SHOW1,"#show_1.png",this.callback,this);
		show.setPosition(cc.p(this.body.width*1.2,this.body.height*0.85));
		show.setOpacity(0);
		show.setCascadeOpacityEnabled(true);
		var line=new Button(show,10,TAG_SHOW_LINE,"#line.png",this.callback,this);
		line.setPosition(cc.p(show.width*0.5, show.height*0.35));
		var fadein=cc.fadeIn(1);
		var fadeout=cc.fadeOut(1);
		show.runAction(cc.sequence(fadein,cc.callFunc(function() {
			line.runAction(cc.moveBy(1,cc.p(0,show.height*0.1)));
		},this),cc.delayTime(3),fadeout));
	},
	initAction:function(){
		var animFrames=[];
		for(var i=1;i<6;i++){
			var str="flask/flask"+i+".png";
			var frame=cc.spriteFrameCache.getSpriteFrame(str);
			animFrames.push(frame);
		}
		var animation=new cc.Animation(animFrames,0.3);
		this.runningAction=cc.repeat(cc.animate(animation),1);
		this.runningAction.retain();
	},
	showLine:function(){
		this.body.runAction(this.runningAction);
	},
	callback:function(p){
		var func=cc.callFunc(function() {
			gg.flow.next();
		},this);
		var action=gg.flow.flow.action;
		switch (p.getTag()) {
		case TAG_FLASK_LID:
			var ber=cc.bezierBy(1, [cc.p(20, 50),cc.p(35,65),cc.p(65, -180)]);
			var rotate=cc.rotateBy(1,90);
			if(action==ACTION_DO1){
				p.runAction(cc.sequence(cc.spawn(ber,rotate),func));
			}else if(action==ACTION_DO2){
				p.runAction(cc.sequence(cc.spawn(ber.reverse(),rotate.reverse()),func));
			}
			
			break;
		default:
			break;
		}
	}
});